'''
Read in the rgb.txt file and write to stdout color definitions that
are usable by gco.py and the names of the color constants.

Each line of the rgb.txt file is expected to be of the form
    r g b\tname
where r, g, and b are integers from 0 to 255.
'''

from __future__ import print_function, division

from pdb import set_trace as xx
import sys

colors = {}
for line in file(sys.argv[1]):
    if not line.strip():
        continue
    numbers, remainder = line.split("\t")
    r, g, b = [int(i)/255 for i in numbers.split()]
    name = ''.join(remainder.split()).lower()
    s = "(%.3f, %.3f, %.3f)" % (r, g, b)
    colors[name] = s
names = colors.keys()
names.sort()
for name in names:
    print("%-22s = %s" % (name, colors[name]))

